package com.mvc.dao;

import com.mvc.annotion.Dao;
import com.mvc.annotion.Resource;
import com.mvc.util.ConnectionUtils;
import com.mvc.util.CurrentCon;

import java.sql.Connection;
import java.sql.PreparedStatement;

/**
 * @ Author xsd
 * @ crate time 2020/6/8 10:01
 * @ 描述
 */
@Dao
public class AccountDao {
    @Resource
    private ConnectionUtils connectionUtils;

    public String insert(String name) throws Exception{
        ConnectionUtils connectionUtils= CurrentCon.getCon();
        Connection con = connectionUtils.getCurrentThreadConn();
        String sql = "insert into a(`name`) VALUES (?)";
        PreparedStatement preparedStatement = con.prepareStatement(sql);
        preparedStatement.setString(1,name);
        boolean i = preparedStatement.execute();
        preparedStatement.close();
        System.out.println(i);
        //con.close();
        return "ok";
    }
}
